package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteBeanUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalServiceOfferConsts;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import java.util.List;
import java.util.Objects;

/**
 * 设备类延期时长属性
 */
public class LocalOrderDelayAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data) {
        // 延期业务
        if (LocalServiceOfferConsts.SERVICE_OFFER_DELAY.equals(data.getServiceOfferId())) {
            // 显示
            KiteAttr effTimeAttr = inst.getAttr("200004127");
            if (Objects.nonNull(effTimeAttr)) {
                effTimeAttr.setShowType("D");
            }
            KiteAttr delayTimeAttr = inst.getAttr("200004103");
            if (Objects.nonNull(delayTimeAttr)) {
                delayTimeAttr.setShowType("D");
            }
            // 隐藏
            KiteAttr experienceTimeAttr = inst.getAttr("200004102");
            if (Objects.nonNull(experienceTimeAttr)) {
                experienceTimeAttr.setShowType("H");
            }
            KiteAttr platTypeAttr = inst.getAttr("200004101");
            if (Objects.nonNull(platTypeAttr)) {
                platTypeAttr.setShowType("H");
            }
            List<AttrValue> attrList = AttrValueCache.get(attr.getAttrId());
            if (Objects.nonNull(attrList)) {
                attr.setAttrValues(KiteBeanUtils.copyPropsForList(attrList, KiteAttrValue.class));
            }
        }

    }
}
